package internal

import (
	"fmt"
	"leaf/timer"
	"server/game/internal/logic/task"
	"time"
)

func init() {
	TaskMilliSecond(33, task.Heartbeat)
}

func TaskSecond(second int64, callback func()) {

	cronExpr, _ := timer.NewCronExpr(fmt.Sprintf("0/%d * * * * *", second))

	skeleton.CronFunc(cronExpr, callback)

}

func TaskMilliSecond(mills int64, callback func()) {
	skeleton.LoopFunc(time.Millisecond*time.Duration(mills), callback)
}
